import configparser

# 获取配置信息
def get_config(section, key):
    config = configparser.ConfigParser()
    # 读取配置文件，用绝对路径，不用相对路径
    config.read('../config.ini')
    value = config.get(section, key)
    return value
def set_config(section,key,value):
    config = configparser.ConfigParser()
    config.read('../config.ini')
    config.set(section,key,value)
    with open('../config.ini', 'w') as configfile:
        config.write(configfile)
if __name__ == '__main__':
    value = get_config('TongYiGetApi', 'api_key')
    print(value)
    if value:
        print(get_config('TongYiGetApi', 'api_key'))
    else:
        print("未获取到配置信息")
    print(get_config('api', 'api_key'))